/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package Outils;

import Servlet.connexionAdmin;
import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author smng2095
 */
public class Hash {
    public static String hashMd5(String chaine){
        try {
            if (chaine==null)return null;
            MessageDigest md = MessageDigest.getInstance("MD5");
            byte[] data = chaine.getBytes();
            md.update(data, 0, data.length);
           
            return (new BigInteger(1,md.digest()).toString(16));
            
        
        } catch (NoSuchAlgorithmException ex) {
            Logger.getLogger(connexionAdmin.class.getName()).log(Level.SEVERE, null, ex);
            return null;
        }
    
    }
}
